package com.example.demo.web.controller;

import com.example.demo.core.handler.exception.ResultBO;
import com.example.demo.core.handler.exception.ResultTool;
import com.example.demo.sys.service.DeptService;
import com.example.demo.sys.service.RoleService;
import com.example.demo.sys.service.bo.DepartmentBO;
import com.example.demo.sys.service.bo.RoleBO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/")
public class RoleController {
    @Autowired
    private RoleService roleService;

    @PostMapping("/role")
    @ResponseBody
    public ResultBO<?> addRole(@RequestBody RoleBO roleBO){
        roleService.addRole(roleBO);
        return ResultTool.success(roleBO);
    }

    @PutMapping("/role")
    @ResponseBody
    public ResultBO<?> updateRole(@RequestBody RoleBO roleBO){
        roleService.updateRole(roleBO);
        return ResultTool.success(roleBO);
    }

    @DeleteMapping("/role/{ids}")
    @ResponseBody
    public ResultBO<?> removeRoles(@PathVariable("ids") List<Integer> ids){
        roleService.removeRolesByIds(ids);
        return ResultTool.success(ids);
    }
}
